package com.happy.common.util;

public class FileExtenstion {
	// ����ļ���׺�� ������.�� ���� xxx.exe ֻ��ȡ exe
	public static String getFileExtenstion(String fileName) {
		try {
			int i = fileName.lastIndexOf(".") + 1;// ��1 �Ժ� �Ϳ���ȥ��.
			char[] souse = fileName.toCharArray();
			StringBuffer buffer = new StringBuffer();
			for (int j = i; j < souse.length; j++) {
				buffer.append(souse[j]);
			}
			return buffer.toString();
		} catch (RuntimeException e) {
			System.out.println("�쳣��Ϣ��" + e.getMessage());
			return "";
		}
	}

	// ����ļ��� �����ļ�·�� ���ǲ�����չ��
	public static String beforeExtenstion(String fileName) {
		try {
			int i = fileName.indexOf(".");
			char[] souse = fileName.toCharArray();
			StringBuffer buffer = new StringBuffer();
			for (int j = 0; j < i; j++) {
				buffer.append(souse[j]);
			}
			return buffer.toString();
		} catch (RuntimeException e) {
			System.out.println("�쳣��Ϣ��" + e.getMessage());
			return "";
		}
	}

	// ����ļ��� ���� E:/mao.txt ����� mao.txt
	public static String getFileName(String path) {
		try {
			int i = path.lastIndexOf("/") + 1;
			char[] source = path.toCharArray();
			StringBuffer buffer = new StringBuffer();
			for (int j = i; j < source.length; j++) {
				buffer.append(source[j]);
			}
			return buffer.toString();
		} catch (RuntimeException e) {
			System.out.println(e.getMessage());
			return "";
		}

	}

}
